<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>医生信息</title>
    <link rel="stylesheet" href="/hospital/Public/css/bootstrap.min.css">
    <script src="/hospital/Public/js/jquery.js"></script>
    <script src="/hospital/Public/js/bootstrap.min.js" ></script>
    <style>
        body{
            margin-top: 5px;
        }
    </style>
</head>
<body>
<div class="container col-lg-6 col-lg-push-3">
    <div class="panel panel-default">
        <div class="panel-heading">
            <h4>医生信息</h4>
        </div>
        <ul class="list-group-item-heading">
            <h4 class="text-primary">姓名 <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </span><input type="text" id="iname" value=""></h4>
        </ul>
        <ul class="list-group-item-heading">
            <h4 class="text-primary">工号 <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </span><input type="text" id="inum" value=""></h4>
        </ul>
        <ul class="list-group-item-heading">
            <h4 class="text-primary">科目 <span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            </span><input type="text" id="imaj"  value=""></h4>
        </ul>
            <br>
                <h4>值班时间表</h4>
            <table class="table" id="tb_schedule">
                <thead>
                <tr class="success">
                    <th>时间</th>
                    <th>上午</th>
                    <th>下午</th>
                </tr>
                </thead>
                <tbody>
                <tr class="">
                    <td>星期一</td>
                    <td>
                        <label>
                            <input type="checkbox" value="1">
                            9:00-11:00
                        </label>
                    </td>
                    <td>
                        <label>
                            <input type="checkbox" value="2">
                            3:00-5:00
                        </label>
                    </td>
                </tr>
                <tr class="">
                    <td>星期二</td>
                    <td>
                        <label>
                            <input type="checkbox" value="3">
                            9:00-11:00
                        </label>
                    </td>
                    <td>
                        <label>
                            <input type="checkbox" value="4">
                            3:00-5:00
                        </label>
                    </td>
                </tr>
                <tr class="">
                    <td>星期三</td>
                    <td>
                        <label>
                            <input type="checkbox" value="5">
                            9:00-11:00
                        </label>
                    </td>
                    <td>
                        <label>
                            <input type="checkbox" value="6">
                            3:00-5:00
                        </label>
                    </td>
                </tr>
                <tr class="">
                    <td>星期四</td>
                    <td>
                        <label>
                            <input type="checkbox" value="7">
                            9:00-11:00
                        </label>
                    </td>
                    <td>
                        <label>
                            <input type="checkbox" value="8">
                            3:00-5:00
                        </label>
                    </td>
                </tr>
                <tr class="">
                    <td>星期五</td>
                    <td>
                        <label>
                            <input type="checkbox" value="9">
                            9:00-11:00
                        </label>
                    </td>
                    <td>
                        <label>
                            <input type="checkbox" value="10">
                            3:00-5:00
                        </label>
                    </td>
                </tr>
                <tr class="">
                    <td>星期六</td>
                    <td>
                        <label>
                            <input type="checkbox" value="11">
                            9:00-11:00
                        </label>
                    </td>
                    <td>
                        <label>
                            <input type="checkbox" value="12">
                            3:00-5:00
                        </label>
                    </td>
                </tr>
                <tr class="">
                    <td>星期日</td>
                    <td>
                        <label>
                            <input type="checkbox" value="13">
                            9:00-11:00
                        </label>
                    </td>
                    <td>
                        <label>
                            <input type="checkbox" value="14">
                            3:00-5:00
                        </label>
                    </td>
                </tr>

                </tbody>
            </table>
    </div>
    <div class=" container col-lg-1 col-lg-push-6">
        <button class="btn btn-success" onclick="javascript: confirm();" >保存</button>
    </div>
</div>
<script type="text/javascript">
    function confirm(){
        var select = $('#tb_schedule input:checkbox:checked')
        var Mon = 0, Tue = 0, Wed = 0, Thu = 0, Fri = 0, Sat = 0, Sun = 0;
        for(var i in select){
            switch (select[i].value){
                case '1' : Mon++;break;
                case '2' : Mon+=2;break;
                case '3' : Tue++;break;
                case '4' : Tue+=2;break;
                case '5' : Wed++;break;
                case '6' : Wed+=2;break;
                case '7' : Thu++;break;
                case '8' : Thu+=2;break;
                case '9' : Fri++;break;
                case '10': Fri+=2;break;
                case '11': Sat++;break;
                case '12': Sat+=2;break;
                case '13': Sun++;break;
                case '14': Sun+=2;break;
            }
        }

        $.ajax({
            url: "<?php echo U('Doctors/addDoctors');?>",
            type: 'POST',
            dataType: 'json',
            data: {
                'dot_name': $('#iname').val(),
                'dot_number': $('#inum').val(),
                'dot_major': $('#imaj').val(),
                'Mon' : Mon,
                'Tue' : Tue,
                'Wed' : Wed,
                'Thu' : Thu,
                'Fri' : Fri,
                'Sat' : Sat,
                'Sun' : Sun
            }, success: function (json) {
                if(json=='0'){
                    alert('己存在此人，请修改后再填吧');
                }else if(json=='1'){
                    alert('添加失败');
                }else if(json=='2'){
                    alert('添加成功');
                }else{
                    alert(json);
                }
            }
        });
    }
</script>
</body>
</html>